<template>
  <a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off"
    @finish="onFinish" @finishFailed="onFinishFailed">
    <a-form-item label="Username" name="username" :rules="[{ required: true, message: 'Please input your username!' }]">
      <a-input v-model:value="formState.username" />
    </a-form-item>

    <a-form-item label="Password" name="password" :rules="[{ required: true, message: 'Please input your password!' }]">
      <a-input-password v-model:value="formState.password" />
    </a-form-item>

    <a-form-item name="remember" :wrapper-col="{ offset: 8, span: 16 }">
      <a-checkbox v-model:checked="formState.remember">Remember me</a-checkbox>
    </a-form-item>

    <a-form-item :wrapper-col="{ offset: 8, span: 16 }">
      <a-button type="primary" html-type="submit">Submit</a-button>
    </a-form-item>
  </a-form>
</template>
<script lang="ts" setup>
import { ref, reactive } from 'vue';

// 接口引入地址
import { getSeller, getLogin } from "@/api/login";

interface FormState {
  username: string;
  password: string;
  remember: boolean;
  tenantId: string
}

const formState = reactive<FormState>({
  username: 'admin',
  password: 'IkMCJPvLEQjhN9U7OUXSy8Ltj7l2XwEAhylobUxGvaD6yM3t04OYOX22RPBMbfVa8Bu1zUmefi59TUmygjmBSwNk2%2Bvog0uUn695Mp758FPjnVnih1%2BxKVuW2H1izqi0Kho0pNai3sQ7aLdPifbOr9SLZPTAVJa3k2ZCgjgWbGE%3D&tenantId',
  remember: true,
  tenantId: '0'
});

const onFinish = async (values: any) => {
  console.log('Success:', values);
  let nameYes = await getName()
  // if(nameYes.code === 200){

  // }
  getLogin(formState).then((response: any) => {
    console.log("结果", response);
  })
    .catch((error: any) => {
      console.log('获取失败！')
    });
};

const onFinishFailed = (errorInfo: any) => {
  console.log('Failed:', errorInfo);
};


function getName() {
  getSeller({ username: 'admin' }).then((response: any) => {
    console.log("结果", response);
    return response;
  })
    .catch((error: any) => {
      console.log('获取失败！')
    });
}
</script>
